<?php

namespace app\common\taglib;

use think\template\TagLib;
use think\facade\Db;
use think\Page;
class MqCms extends TagLib
{
    protected $tags = [
        'myppt' => ['attr' => 'title,limit,id,cid,link,des,order,status', 'close' => 1],
        'doc' => ['attr' => 'type,field,where,cateid,order,day,cache,pagenum,minscore,maxscore,ext,usertype,uid,own,how,search,similar,status,exceptid,choice,top', 'close' => 1],
    ];

    public function tagDoc($tag,$content)
    {
        $type = isset($tag['type']) ? trim($tag['type']) : 'lists';
        $field = isset($tag['field']) ? trim($tag['field']) : '*';
        $map = isset($tag['where']) ? trim($tag['where']) : '';
        $cateid = isset($tag['cateid']) ? trim($tag['cateid']) : '0';
        $order = isset($tag['order']) ? trim($tag['order']) : 'id DESC';
        $day = isset($tag['day']) ? trim($tag['day']) : '0';
        $cache = isset($tag['cache']) ? trim($tag['cache']) : '60';
        $pagenum = isset($tag['pagenum']) ? trim($tag['pagenum']) : '0';
        $minscore = isset($tag['minscore']) ? trim($tag['minscore']) : 'min';
        $maxscore = isset($tag['maxscore']) ? trim($tag['maxscore']) : 'max';
        $ext = isset($tag['ext']) ? trim($tag['ext']) : '0';
        $usertype = isset($tag['usertype']) ? trim($tag['usertype']) : '0';
        $uid = isset($tag['uid']) ? trim($tag['uid']) : '0';
        $own = isset($tag['own']) ? trim($tag['own']) : '0';//为1时表示调用该uid的文档
        $how = isset($tag['how']) ? trim($tag['how']) : '';
        $search = isset($tag['search']) ? trim($tag['search']) : '';
        $similar = isset($tag['similar']) ? trim($tag['similar']) : '0';
        $status = isset($tag['status']) ? trim($tag['status']) : '1';
        $exceptid = isset($tag['exceptid']) ? trim($tag['exceptid']) : '0';//除了哪个文档不显示
        $choice = isset($tag['choice']) ? trim($tag['choice']) : '0';
        $top = isset($tag['top']) ? trim($tag['top']) : '0';

        $str = '<?php ';
        $str .= '$list = new \app\common\taglib\ht\tagLists();';
        $str .= '$data = $list->getLists("' . $type . '","' . $field . '","' . $map . '","' . $cateid . '","' . $order . '","' . $day . '","' . $cache . '","' . $pagenum . '","' . $minscore . '","' . $maxscore . '","' . $ext . '","' . $usertype . '","' . $uid . '","' . $own . '","' . $how . '","' . $search . '","' . $similar . '","' . $status . '","' . $exceptid . '","' . $choice . '","' . $top . '");';
        $str .= '?>';
        $str .= $content;
        return $str;
    }
}